﻿using MediatR;
using Production_Get.API.Infrastructures.Interfaces;
using Return.Enum;
using THE_WIND_RISES.Common.Domans.Produce.Customers;
using THE_WIND_RISES.Common.Dtos;

namespace Production_Get.API.Application.Commands.OrderShow
{
    //客户下拉
    public class CustomerShowHandler : IRequestHandler<CustomerShowCommend, Result>
    {
        private readonly IBaseRepositoryGet<Customer> Customer;

        public CustomerShowHandler(IBaseRepositoryGet<Customer> Customer)
        {
            this.Customer = Customer;
        }

        public async Task<Result> Handle(CustomerShowCommend request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = (int)CommonErrorCodes.Search };

            string sql = "SELECT * FROM Customer";
            var list = Customer.GetAll(sql, default).ToList();
            if (list != null)
            {
                result.Code = (int)CommonErrorCodes.Success;
                result.Data = list;
                result.Msg = "显示成功";
            }

            return result;
        }
    }
}
